package com.arron.state;
//受限状态
public class RestrictedState extends AccountState{
    public RestrictedState(AccountState state) {
        super.acc =state.acc;
    }
    @Override
    public void deposit(double amount) {
        acc.setBalance(acc.getBalance()+amount);
        stateCheck();
    }

    @Override
    public void withdraw(double amount) {
        System.out.println("账号受限，取款失败");
    }

    @Override
    public void computerInterest() {
        System.out.println("受限状态，计算利息！");
    }

    @Override
    public void stateCheck() {
        if(acc.getBalance()>0){
            acc.setState(new NormalState(this));
        }
        else if(acc.getBalance()>-2000){
            acc.setState(new OverDraftState(this));
        }
    }
}
